#{extends 'master.html' /}
<div>
    <h3 class="categoryTitle">
    ${brand.title}
    </h3>
    <div class="clear"></div>
</div>
<div class="page-block">
    <a href="@{BrandAdmin.list()}">Назад</a>
    <div class="clear"></div>

#{if brand.imagesCount > 0}
    <img src="@{Product.brandImage(brand.id, 1, 100, 70, 'png')}"/>
#{/if}
    <h3>Google images:</h3>
    <form action="@{BrandAdmin.saveImage(brand.id)}" method="POST">
    <div class="pager">
        <ul>
        #{list items:googleImageResult.cursor.pages, as:'page'}
            #{if (googleImageResult.cursor.currentPageIndex+1) == page.label}
                <li class="selected">
                    <span>${page.label}</span></li>
            #{/if}
            #{else}
                <li><a href="@{BrandAdmin.display(brand.id, page.start)}">${page.label}</a></li>
            #{/else}
        #{/list}
        </ul>
    </div>

    <ul class="brand-images">
    #{list items:googleImageResult.results, as:'image'}
        <li>
            <div><input type="radio" name="imageUrl" id="imageUrl_${image.imageId}" value="${image.url}" /></div>
            <a href="${image.url}">
                <img src="${image.tbUrl}" alt="" width="${tbWidth}" height="${tbHeight}"/>
            </a>

        </li>
    #{/list}
    </ul>

    <div class="pager">
        <ul>
        #{list items:googleImageResult.cursor.pages, as:'page'}
            #{if (googleImageResult.cursor.currentPageIndex+1) == page.label}
                <li class="selected">
                    <span>${page.label}</span></li>
            #{/if}
            #{else}
                <li><a href="@{BrandAdmin.display(brand.id, page.start)}">${page.label}</a></li>
            #{/else}
        #{/list}
        </ul>
    </div>
        <input type="submit" value="Сохранить" />
    </form>
</div>